package cn.ml.gaoJi.jiHe.set;



import cn.ml.gaoJi.jiHe.list.NewsTitle;

import java.util.HashSet;
import java.util.Iterator;

public class MyHashSet {
    public static void main(String[] args) {
        NewsTitle title1 = new NewsTitle(1,"1-北京晴天了1","admid");
        NewsTitle title2 = new NewsTitle(1,"2-北京晴天了2","admid");
        NewsTitle title3 = new NewsTitle(1,"3-北京晴天了3","admid");
        NewsTitle title4 = new NewsTitle(1,"4-北京晴天了4","admid");
        NewsTitle title5 = new NewsTitle(1,"5-北京晴天了5","admid");
        NewsTitle title6 = new NewsTitle(1,"6-北京晴天了5","admid");
        NewsTitle title7 = new NewsTitle(1,"7-北京晴天了5","admid");

        HashSet<NewsTitle> set = new HashSet<>();
        set.add(title1);
        set.add(title2);
        set.add(title3);
        set.add(title4);

        System.out.println("set自己"+set);
        for(NewsTitle title:set){
            System.out.println(title.getId()+title.getTitle());
        }

        System.out.println("*****************");

        Iterator<NewsTitle> itor = set.iterator();
        while (itor.hasNext()){
            NewsTitle title = itor.next();
            //System.out.println(itor.next().getId()+itor.next().getTitle());
            //System.out.println("***********");
            System.out.println(title.getId()+title.getTitle());
        }



    }
}
